package com.sara.web.filter;

import javax.servlet.*;
import java.io.IOException;

public class EncodingFilter extends AbstractFilter{

    String encoding = "UTF-8";

    @Override
    public void init(FilterConfig config) throws ServletException{

        String encoding = config.getInitParameter("encoding");
        if(encoding == null){
            this.encoding = encoding;
        }

    }

    @Override
    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
        req.setCharacterEncoding(encoding);
        chain.doFilter(req,resp);
    }


}
